/**
 * 1.2.7. Regular expression operators
 */

import java.util.regex.Matcher
import java.util.regex.Pattern

def p = ~/foo/
println p
assert p instanceof Pattern

//=~ creates a matcher
def text = "some text to match"
def m = text =~ /match/
println m
assert m instanceof Matcher
if (!m) {
    throw new RuntimeException("Oops, text not found!")
}

//==~ matches the subject with the regular expression, but match must be strict
m = text ==~ /match/
println m
assert m instanceof Boolean
if (m) {
    throw new RuntimeException("Should not reach that point!")
}

println text ==~ /some/  // false
println text ==~ /some.*/  // true
